/*
 * $Header: $
 * $Id$
 *
 * Copyright (c) 2011, Michael DePhillips. All Rights Reserved.
 * This code may not be used without the express written permission
 * of the copyright holder, Michael DePhillips.
 */

package com.facebook.bannermaker.android.activity.template;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TableRow;
import android.widget.TextView;

import com.facebook.bannermaker.android.R;


/**
 * Display the list groups of banner templates (genres)
 * 
 * @author Michael DePhillips
 * 
 */
public class GroupObjectListAdaptor extends BaseAdapter {

    //    private static final String LOG_TAG = BrowseObjectListAdaptor.class.getName();
    //    implements OnClickListener
    private List<String> m_groups = null;
    private Context m_context;


    /**
     * 
     * @param browseObjectBeanList
     * @param context
     */
    public GroupObjectListAdaptor(List<String> groups, Context context) {
        m_groups = groups;
        m_context = context;
    }

    /**
     * Configure each object row.
     */
    //    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        String group = m_groups.get(position);
        LinearLayout itemLayout = (LinearLayout) LayoutInflater.from(m_context).inflate(R.layout.template_group_item, parent,
                false);

        TableRow tableRow = (TableRow) itemLayout.findViewById(R.id.BrowseObjectRow);
        tableRow.setTag(group);

        // apply the banner to the imageview
        TextView groupText = (TextView) itemLayout.findViewById(R.id.template_group_name);
        groupText.setText(group);

        return itemLayout;

    }

    //    @Override
    public int getCount() {
        return m_groups.size();
    }

    //    @Override
    public String getItem(int position) {
        return m_groups.get(position);
    }

    //    @Override
    public long getItemId(int position) {
        return 0;
    }
}
